﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using VOL;
using BLL;
using System.Data;

namespace Shopper
{
    public partial class rptHoaDon : DevExpress.XtraReports.UI.XtraReport
    {
        public rptHoaDon()
        {
            InitializeComponent();
        }

        public void DataBind()
        {
            lblMaHD.DataBindings.Add("Text", DataSource, "MaHD");
            lblDiaChi.DataBindings.Add("Text", DataSource, "DiaChi");
            lblDienThoai.DataBindings.Add("Text", DataSource, "DienThoai");
            lblEmail.DataBindings.Add("Text", DataSource, "Email");
            lblNgayHD.DataBindings.Add("Text", DataSource, "NgHD");
            lblTenKhach.DataBindings.Add("Text", DataSource, "HoTen");
            //lblTongTien.DataBindings.Add("Text", DataSource, "");
        }

        private void xrSubreport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            int MaHD = int.Parse(lblMaHD.Text);

            ChiTietHoaDonBL chiTietBl = new ChiTietHoaDonBL();
            DataTable dtChiTiet = chiTietBl.getDataReport(MaHD);

            rptHoaDonChiTiet _rptHoaDonChiTiet = new rptHoaDonChiTiet();
            _rptHoaDonChiTiet.DataSource = dtChiTiet;
            _rptHoaDonChiTiet.DataBind();
            _rptHoaDonChiTiet.CreateDocument();

            xrSubreport1.ReportSource = _rptHoaDonChiTiet;
        }
    }
}
